home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
new.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-26
|
47KB
|
1,996 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATUtilities Online Help ** */
/* ** Copright (C) 1992-1993 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ******************************************************************* */
#define PAGE_INDEX 1
#define PAGE_TEXT 2
#define PAGE_MEMORY 199
#include "ATUtilities.h"
/*
#define CreateBoolGadget(win,x,y,w,h,text,id) CreateBoolToggleGadget(0,win,x,y,w,h,text,id)
#define CreateMinGadget(win,x,y,w,h,id) CreateBoolToggleGadget(4,win,x,y,w,h,0L,id)
*/
extern struct Library *DiskfontBase;
/* feste Strukturen */
UBYTE *HelpName="SYS:PC/ATUtilities/OnlineHelp.prefs";
struct TextAttr Opal=
{
"opal.font",
9,
FS_NORMAL,
FPF_DISKFONT
};
struct OHPrefs
{
UBYTE Cache;
UBYTE Numbers;
UBYTE NumInput;
UBYTE PAL;
};
struct Page
{
UWORD Length;
UWORD Flags;
ULONG Offset;
ULONG TextOffset;
ULONG GadgetOffset;
ULONG PictureOffset;
};
struct Pages
{
struct Page Page[1000];
};
#define POFFSET(x) hd->Pages->Page[x].PictureOffset
#define GOFFSET(x) hd->Pages->Page[x].GadgetOffset
#define TOFFSET(x) hd->Pages->Page[x].TextOffset
#define OFFSET(x) hd->Pages->Page[x].Offset
#define LENGTH(x) hd->Pages->Page[x].Length
#define FLAGS(x) hd->Pages->Page[x].Flags
struct HelpData
{
struct OHPrefs OHPrefs;
struct Screen *Screen;
struct Window *MainWindow;
struct Window *IndexWindow;
struct Window *TextWindow;
struct MenuStrip *MenuStrip;
struct Menu *DateiMenu;
struct Menu *QVMenu;
struct Menu *BilderMenu;
struct Window *GadWindow;
struct Gadget *PropGadget;
struct PropInfo *PropInfo;
struct RastPort *MainRastPort;
struct RastPort *IndexRastPort;
struct MsgPort *MainUserPort;
struct MsgPort *IndexUserPort;
struct MsgPort *TextUserPort;
struct MsgPort *GadUserPort;
struct TextFont *OpalFont;
struct ViewPort *ViewPort;
struct MsgPort *ConPort;
struct IOStdReq *ConReq;
LONG ConDev;
struct FileHandle *HelpFile;
UBYTE *Memory;
struct Pages *Pages;
ULONG Picture[100];
UWORD Page;
UWORD Flags;
ULONG MainWindowSM;
ULONG IndexWindowSM;
ULONG TextWindowSM;
ULONG GadWindowSM;
ULONG WaitSM;
UWORD NextPage[4];
UWORD LastPage[PAGE_MEMORY+1];
UBYTE LastPagePos;
UBYTE LastPageSelect;
UWORD ShowLastPageBack;
UBYTE String[200];
BOOL NTSC;
UWORD Rows;
UWORD MaxItems;
UWORD PropDown;
UWORD CacheOn;
ULONG CacheSize;
LONG CachePos;
LONG CacheLastPos;
UBYTE *CacheMemory;
UBYTE InputCount;
UWORD Input[3];
UWORD IGy;
UWORD IGw;
UWORD IGs;
UWORD IGPCount;
struct Gadget *IndexGadgets[64];
UWORD IndexGadgetPages[64];
UWORD MenuPageCount;
UWORD MenuNames[25][70];
UWORD MenuPages[25];
UBYTE MenuPicCount;
UBYTE MenuPicNames[25][16];
UBYTE MenuPics[25];
UWORD PropBody;
UWORD LineCount;
UWORD CurrentLine;
UBYTE *Lines[2000];
};
UWORD Colors[]={0x97a,0x222,0xddd,0xff5,0xdd6,0xccc,0xfff,0x22f};
BOOL OpenHelp();
VOID CloseHelp();
VOID ConWrite();
VOID RefreshGadWindow();
VOID GetTitle();
VOID LoadPage();
VOID ShowIndexPage();
VOID ShowTextPage();
VOID RemIndexGadgets();
VOID NewProp();
VOID ShowPart();
VOID MakeMenu();
VOID Hinweise();
VOID GetPictures();
VOID Prefs();
LONG CacheRead();
LONG CacheSeek();
VOID LoadAPicture();
VOID AddPage();
BOOL ShowPicture();
BOOL DisplayPicture();
UBYTE *GetOpalLine();
UBYTE *GetOpalLine450();
VOID RemoveMenuStrip();
VOID UseMenuStrip();
UBYTE MouseButton();
struct MenuStrip *BuildMenuStrip();
struct Menu *AddMenu();
struct Menu *AddItem();
/* Informationen anzeigen */
VOID ShowInfo(win,scr)
struct Window *win;
struct Screen *scr;
{
WBenchToFront();
InformationBox("ATUtilities Online Help - Information",
"Online Help - Version 2.0",
"Copyright (C) 1993 by",
"Thomas Dreibholz",
"All rights reserved.",
"SYS:PC/ATUtilities/Icons/Help");
ScreenToFront(scr);
ActivateWindow(win);
}
/* Online-Hilfe-Funktion */
VOID Help(name,seite)
UBYTE *name;
UWORD seite;
{
UBYTE s[32];
REGISTER ULONG Class;
REGISTER BOOL ende,bool;
REGISTER UWORD i,j,Code;
REGISTER UWORD MenuNum,ItemNum;
REGISTER ULONG Signale;
register struct IntuiMessage *msg;
register struct HelpData *hd;
register struct Gadget *gad;
if(DiskfontBase==NULL)
{
InfoRequest("Keine Diskfont-Library!");
return;
}
hd=AllocMem(sizeof(struct HelpData),MEMF_CLEAR|MEMF_PUBLIC);
if(hd==NULL)
{
ErrorRequest(ERROR_ALLOC);
return;
}
bool=OpenHelp(hd,name);
if(bool==TRUE)
{
ende=FALSE;
while(ende==FALSE)
{
Signale=Wait(hd->WaitSM);
if((hd->GadUserPort!=NULL) && (Signale & hd->GadWindowSM))
{
msg=GetMsg(hd->GadUserPort);
while(msg!=NULL)
{
Class=msg->Class;
gad=msg->IAddress;
ReplyMsg(msg);
if(Class==GADGETUP)
{
j=gad->GadgetID;
switch(j)
{
case 1000:
if(hd->LastPageSelect>0)
{
hd->LastPageSelect--;
hd->ShowLastPageBack++;
LoadPage(hd,hd->LastPage[hd->LastPageSelect],FALSE);
}
break;
case 2000:
if(hd->ShowLastPageBack>0)
{
hd->ShowLastPageBack--;
hd->LastPageSelect++;
LoadPage(hd,hd->LastPage[hd->LastPageSelect],FALSE);
}
break;
default:
LoadPage(hd,hd->NextPage[j],TRUE);
break;
}
}
else if(Class==ACTIVEWINDOW)
ActivateWindow(hd->MainWindow);
msg=GetMsg(hd->GadUserPort);
}
}
if(Signale & hd->MainWindowSM)
{
msg=GetMsg(hd->MainUserPort);
while(msg!=NULL)
{
Class=msg->Class;
Code=msg->Code;
gad=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case GADGETUP:
j=gad->GadgetID;
switch(j)
{
case 1:
ende=TRUE;
break;
case 2:
LoadPage(hd,0,TRUE);
break;
case 3:
if((hd->Flags==PAGE_TEXT)&&(hd->LineCount>hd->Rows))
{
hd->PropDown=0;
j=hd->PropInfo->VertPot/(65535/hd->PropBody);
ShowPart(hd,j);
}
break;
}
break;
case GADGETDOWN:
j=gad->GadgetID;
switch(j)
{
case 3:
if((hd->Flags==PAGE_TEXT)&&(hd->LineCount>hd->Rows))
{
hd->PropDown=1;
}
break;
}
break;
case MOUSEMOVE:
if(hd->PropDown!=0)
{
AbortIO(hd->ConReq);
j=hd->PropInfo->VertPot/(65535/hd->PropBody);
ShowPart(hd,j);
}
break;
case MENUPICK:
MenuNum=MENUNUM(Code);
ItemNum=ITEMNUM(Code);
switch(MenuNum)
{
case 2:
switch(ItemNum)
{
case 0:
ende=TRUE;
break;
case 2:
ShowInfo(hd->MainWindow,hd->Screen);
break;
case 3:
Hinweise(hd);
break;
case 4:
Prefs(hd);
break;
}
break;
case 1:
if(hd->Flags==PAGE_TEXT)
{
if((hd->MenuPageCount!=0)&&(ItemNum<=hd->MenuPageCount))
LoadPage(hd,hd->MenuPages[hd->MenuPageCount-ItemNum-1],TRUE);
}
break;
case 0:
if((hd->MenuPicCount!=0)&&(ItemNum<=hd->MenuPicCount))
LoadAPicture(hd,hd->MenuPics[hd->MenuPicCount-ItemNum-1]);
ActivateWindow(hd->MainWindow);
break;
}
break;
case VANILLAKEY:
if(hd->OHPrefs.NumInput)
{
if((Code>='0')&&(Code<='9'))
{
hd->Input[hd->InputCount]=Code;
hd->InputCount++;
sprintf(&s,"Seiteneingabe: #%c%c%c",hd->Input[0],
hd->Input[1],
hd->Input[2]);
DrawCNTextBorder(hd->MainWindow,320,10,310,12,&s);
if(hd->InputCount>2)
{
LoadPage(hd,(hd->Input[0]-48)*100+
(hd->Input[1]-48)*10+
(hd->Input[2]-48),TRUE);
}
}
}
break;
}
msg=GetMsg(hd->MainUserPort);
}
}
if(Signale & hd->IndexWindowSM)
{
msg=GetMsg(hd->IndexUserPort);
while(msg!=NULL)
{
Class=msg->Class;
gad=msg->IAddress;
ReplyMsg(msg);
if(Class==GADGETUP)
{
j=gad->GadgetID;
LoadPage(hd,hd->IndexGadgetPages[j],TRUE);
}
else if(Class==ACTIVEWINDOW)
ActivateWindow(hd->MainWindow);
msg=GetMsg(hd->IndexUserPort);
}
}
if(Signale & hd->TextWindowSM)
{
msg=GetMsg(hd->TextUserPort);
while(msg!=NULL)
{
Class=msg->Class;
ReplyMsg(msg);
if(Class==ACTIVEWINDOW)
ActivateWindow(hd->MainWindow);
msg=GetMsg(hd->TextUserPort);
}
}
}
}
CloseHelp(hd);
FreeMem(hd,sizeof(struct HelpData));
}
BOOL OpenHelp(hd,name)
struct HelpData *hd;
UBYTE *name;
{
register struct FileHandle *fh;
UBYTE c;
WORD a,i;
LONG b;
static struct NewScreen HelpScreen=
{
0,0,640,256,3,
0,1,
HIRES,
CUSTOMSCREEN,
NULL,
NULL,NULL,NULL
};
static struct NewWindow MainWindowDef=
{
0,0,640,256,
0,2,
GADGETUP|MENUPICK|GADGETDOWN|MOUSEMOVE|VANILLAKEY,
ACTIVATE|BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
10,16,640,256,
CUSTOMSCREEN
};
static struct NewWindow IndexWindowDef=
{
11,26,582,210,
0,1,
GADGETUP|ACTIVEWINDOW,
BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
10,16,640,256,
CUSTOMSCREEN
};
static struct NewWindow TextWindowDef=
{
12,27,580,208,
0,1,
ACTIVEWINDOW,
NOCAREREFRESH|BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
10,16,640,256,
CUSTOMSCREEN
};
hd->ConDev=-1L;
hd->HelpFile=Open(name,MODE_OLDFILE);
if(hd->HelpFile==NULL)
{
MultiRequest("Kann Hilfedatei nicht öffnen:",name,"Okay",NULL);
return(FALSE);
}
hd->OpalFont=GetOpalFont();
if(hd->OpalFont==NULL)
{
InfoRequest("Opal-Font fehlt!");
return(FALSE);
}
fh=Open(HelpName,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&hd->OHPrefs,sizeof(struct OHPrefs));
Close(fh);
}
if(hd->OHPrefs.PAL==0)
{
hd->NTSC=TRUE;
hd->Rows=18;
hd->MaxItems=18;
HelpScreen.Height=200;
MainWindowDef.Height=200;
IndexWindowDef.Height=154;
TextWindowDef.Height=152;
}
else
{
hd->NTSC=FALSE;
hd->Rows=25;
hd->MaxItems=24;
}
hd->Screen=OpenScreen(&HelpScreen);
if(hd->Screen==NULL)
{
InfoRequest("Kann Screen nicht öffnen!");
return(FALSE);
}
hd->ViewPort=&hd->Screen->ViewPort;
LoadRGB4(hd->ViewPort,&Colors,8);
MainWindowDef.Screen=hd->Screen;
IndexWindowDef.Screen=hd->Screen;
TextWindowDef.Screen=hd->Screen;
hd->IndexWindow=OpenWindow(&IndexWindowDef);
if(hd->IndexWindow==NULL)
{
InfoRequest("Kann Fenster nicht öffnen!");
return(FALSE);
}
hd->TextWindow=OpenWindow(&TextWindowDef);
if(hd->TextWindow==NULL)
{
InfoRequest("Kann Fenster nicht öffnen!");
return(FALSE);
}
hd->MainWindow=OpenWindow(&MainWindowDef);
if(hd->MainWindow==NULL)
{
InfoRequest("Kann Fenster nicht öffnen!");
return(FALSE);
}
hd->MainRastPort=hd->MainWindow->RPort;
hd->IndexRastPort=hd->IndexWindow->RPort;
hd->MainUserPort=hd->MainWindow->UserPort;
hd->IndexUserPort=hd->IndexWindow->UserPort;
hd->TextUserPort=hd->TextWindow->UserPort;
hd->MainWindowSM=(1L<<hd->MainUserPort->mp_SigBit);
hd->IndexWindowSM=(1L<<hd->IndexUserPort->mp_SigBit);
hd->TextWindowSM=(1L<<hd->TextUserPort->mp_SigBit);
hd->MainWindow->UserData=NULL;
hd->IndexWindow->UserData=NULL;
hd->TextWindow->UserData=NULL;
SetFont(hd->MainRastPort,hd->OpalFont);
SetFont(hd->IndexRastPort,hd->OpalFont);
CreateBoolGadget(hd->MainWindow,10,10,150,12,"Ende",1);
CreateBoolGadget(hd->MainWindow,165,10,150,12,"Index",2);
if(hd->NTSC==FALSE) i=211; else i=155;
hd->PropGadget=CreatePropGadget(hd->MainWindow,600,25,30,i,0,0,0,(65535/10),3);
hd->PropInfo=hd->PropGadget->SpecialInfo;
DrawNBorder(hd->MainWindow,10,25,584,i);
SetAPen(hd->MainRastPort,3);
WriteText(hd->MainRastPort,40,40,"ATUtilities Online-Hilfe - Version 2.0");
WriteText(hd->MainRastPort,40,60,"Hilfedatei wird bearbeitet.");
WriteText(hd->MainRastPort,40,80,"Bitte warten...");
hd->ConPort=CreatePort("onlinehelp-console.port",0L);
if(hd->ConPort==NULL)
{
InfoRequest("Kann MsgPort nicht erstellen!");
return(FALSE);
}
hd->ConReq=CreateExtIO(hd->ConPort,sizeof(struct IOStdReq));
if(hd->ConReq==NULL)
{
InfoRequest("Kann IOStdReq nicht erstellen!");
return(FALSE);
}
hd->ConReq->io_Data=hd->TextWindow;
hd->ConReq->io_Length=sizeof(struct Window);
hd->ConDev=OpenDevice("console.device",0L,hd->ConReq,0L);
if(hd->ConDev!=0)
{
InfoRequest("Kann Console-Device nicht öffnen!");
return(FALSE);
}
ConWrite(hd,"\x9b");
ConWrite(hd,"0;33;40m");
if(hd->OHPrefs.Cache!=0)
{
Seek(hd->HelpFile,0,OFFSET_END);
hd->CacheSize=Seek(hd->HelpFile,0,OFFSET_BEGINNING);
hd->CacheMemory=AllocMem(hd->CacheSize,MEMF_CLEAR|MEMF_PUBLIC);
if(hd->CacheMemory!=NULL)
{
b=Read(hd->HelpFile,hd->CacheMemory,hd->CacheSize);
if(b==hd->CacheSize) hd->CacheOn=1;
}
}
hd->Pages=AllocMem(sizeof(struct Pages),MEMF_CLEAR|MEMF_PUBLIC);
if(hd->Pages==NULL)
{
ErrorRequest(ERROR_ALLOC);
return(FALSE);
}
hd->Memory=AllocMem(50000,MEMF_CLEAR|MEMF_PUBLIC);
if(hd->Memory==NULL)
{
ErrorRequest(ERROR_ALLOC);
return(FALSE);
}
CacheSeek(hd,-4,OFFSET_END);
CacheRead(hd,&b,4L);
CacheSeek(hd,b,OFFSET_BEGINNING);
for(i=0;i<1000;i++)
{
CacheRead(hd,&c,1L);
if(c!=0)
{
CacheRead(hd,&a,2L);
CacheRead(hd,&b,4L);
LENGTH(i)=a;
OFFSET(i)=b;
FLAGS(i)=c;
CacheRead(hd,&b,4L);
TOFFSET(i)=b;
CacheRead(hd,&b,4L);
GOFFSET(i)=b;
CacheRead(hd,&b,4L);
POFFSET(i)=b;
}
}
for(i=0;i<100;i++)
{
CacheRead(hd,&hd->Picture[i],4L);
}
hd->MenuStrip=BuildMenuStrip(hd->MainWindow,7,AUTOBACKPEN);
if(hd->MenuStrip==NULL)
{
InfoRequest("Kein Speicher für Menu!");
return(FALSE);
}
hd->Page=12345;
LoadPage(hd,0,TRUE);
return(TRUE);
}
VOID CloseHelp(hd)
struct HelpData *hd;
{
if(hd->MenuStrip) RemoveMenuStrip(hd->MenuStrip,TRUE);
if(hd->ConDev==0) CloseDevice(hd->ConReq);
if(hd->GadWindow) DeleteStdWindow(hd->GadWindow);
if(hd->TextWindow) DeleteStdWindow(hd->TextWindow);
if(hd->IndexWindow)
{
RemIndexGadgets(hd);
DeleteStdWindow(hd->IndexWindow);
}
if(hd->MainWindow) DeleteStdWindow(hd->MainWindow);
if(hd->Screen) CloseScreen(hd->Screen);
if(hd->ConReq) DeleteExtIO(hd->ConReq);
if(hd->ConPort) DeletePort(hd->ConPort);
if(hd->Pages) FreeMem(hd->Pages,sizeof(struct Pages));
if(hd->Memory) FreeMem(hd->Memory,50000);
if(hd->CacheMemory) FreeMem(hd->CacheMemory,hd->CacheSize);
if(hd->OpalFont) CloseFont(hd->OpalFont);
if(hd->HelpFile) Close(hd->HelpFile);
}
VOID ConWrite(hd,text)
struct HelpData *hd;
UBYTE *text;
{
hd->ConReq->io_Data=text;
hd->ConReq->io_Length=strlen(text);
hd->ConReq->io_Command=CMD_WRITE;
SendIO(hd->ConReq);
}
VOID RefreshGadWindow(hd)
struct HelpData *hd;
{
WORD i;
static struct NewWindow GadWindowDef=
{
0,238,640,15,
0,1,
GADGETUP|ACTIVEWINDOW,
BORDERLESS,
NULL,NULL,NULL,NULL,NULL,
10,10,640,256,
CUSTOMSCREEN
};
if(hd->NTSC==TRUE) GadWindowDef.TopEdge=182;
if(hd->GadWindow!=NULL)
DeleteStdWindow(hd->GadWindow);
GetTitle(hd,hd->Page);
DrawMNTextBorder(hd->MainWindow,320,10,310,12,hd->Memory);
GadWindowDef.Screen=hd->Screen;
hd->GadWindow=OpenWindow(&GadWindowDef);
if(hd->GadWindow!=NULL)
{
SetFont(hd->GadWindow->RPort,hd->OpalFont);
hd->GadUserPort=hd->GadWindow->UserPort;
hd->GadWindowSM=(1L<<hd->GadUserPort->mp_SigBit);
for(i=0;i<=3;i++) hd->NextPage[i]=0xFFFF;
if(hd->Page>0)
{
for(i=(hd->Page-1);i>=0;i--)
if(FLAGS(i)==PAGE_INDEX)
{ hd->NextPage[0]=i; break; }
}
if(hd->Page!=0) hd->NextPage[3]=0;
if(hd->Page<999)
{
for(i=(hd->Page+1);i<=999;i++)
if(FLAGS(i)==PAGE_INDEX)
{ hd->NextPage[3]=i; break; }
}
if(hd->Page>0)
{
for(i=(hd->Page-1);i>=0;i--)
{
if(FLAGS(i)!=0)
{
if(FLAGS(i)==PAGE_TEXT)
hd->NextPage[1]=i;
break;
}
}
}
if(hd->Page<999)
{
for(i=(hd->Page+1);i<=999;i++)
{
if(FLAGS(i)!=0)
{
if(FLAGS(i)==PAGE_TEXT)
hd->NextPage[2]=i;
break;
}
}
}
for(i=0;i<=3;i++)
{
if(hd->NextPage[i]!=0xFFFF)
{
GetTitle(hd,hd->NextPage[i]);
CreateMBoolGadget(hd->GadWindow,38+(i*143),1,135,12,hd->Memory,i);
}
}
if(hd->LastPageSelect>0)
CreateBoolGadget(hd->GadWindow,10,1,22,12,"«",1000);
if(hd->ShowLastPageBack>0)
CreateBoolGadget(hd->GadWindow,608,1,22,12,"»",2000);
}
else
{
hd->GadWindowSM=0;
hd->GadUserPort=NULL;
}
hd->WaitSM=hd->GadWindowSM+hd->MainWindowSM+hd->IndexWindowSM+hd->TextWindowSM;
}
VOID GetTitle(hd,p)
struct HelpData *hd;
LONG p;
{
LONG i,o;
i=OFFSET(p);
if(i!=0)
{
o=CacheSeek(hd,i,OFFSET_BEGINNING);
if(hd->OHPrefs.Numbers==0)
{
CacheRead(hd,hd->Memory,1024L);
}
else
{
sprintf(hd->Memory,"#%03ld: ",p);
CacheRead(hd,&hd->Memory[6],1024L);
}
CacheSeek(hd,o,OFFSET_BEGINNING);
}
else hd->Memory[0]=0x00;
}
VOID LoadPage(hd,num,add)
struct HelpData *hd;
UWORD num;
BOOL add;
{
hd->InputCount=0;
hd->Input[1]='-';
hd->Input[2]='-';
if(num==hd->Page) return;
if(OFFSET(num)!=0)
{
hd->Page=num;
hd->Flags=FLAGS(num);
if(add==TRUE) AddPage(hd);
RemIndexGadgets(hd);
switch(hd->Flags)
{
case PAGE_INDEX:
NewProp(hd,1);
ShowIndexPage(hd,num);
break;
case PAGE_TEXT:
ShowTextPage(hd,num);
break;
}
}
else
{
DisplayBeep(hd->Screen);
DisplayBeep(hd->Screen);
}
}
VOID ShowIndexPage(hd,num)
struct HelpData *hd;
UWORD num;
{
UBYTE *m;
LONG i,j,max;
UWORD x,y,w,xx,yy;
UWORD wort;
UBYTE c;
x=15; y=11;
j=TOFFSET(num);
if(j!=0)
{
i=LENGTH(num);
CacheSeek(hd,j,OFFSET_BEGINNING);
CacheRead(hd,hd->Memory,i);
/* ----- Testausgabe -------------------------------------------------- */
SetAPen(hd->IndexRastPort,3);
m=hd->Memory;
for(j=0;j<i;j++)
{
c=m[j];
if(c==0x00)
{
x=15;
y+=10;
}
else
{
Move(hd->IndexRastPort,x,y);
Text(hd->IndexRastPort,&c,1L);
x=x+TextLength(hd->IndexRastPort,&c,1L);
}
}
}
/* ----- Gadgets ------------------------------------------------------ */
j=GOFFSET(num);
if(j!=0)
{
CacheSeek(hd,j,OFFSET_BEGINNING);
j=0; y-=5;
CacheRead(hd,&wort,2L);
while((wort!=0xFFFF)&&(j<=63))
{
hd->IndexGadgetPages[j]=wort;
j++;
CacheRead(hd,&wort,2L);
}
hd->IGPCount=j;
if(hd->NTSC==FALSE) max=198; else max=142;
hd->IGy=(max-y)/27;
hd->IGs=hd->IGPCount/hd->IGy;
hd->IGw=((552-((hd->IGs-1)*5))/hd->IGs);
x=15;
for(i=0;i<hd->IGPCount;i++)
{
if(hd->IndexGadgetPages[i]!=2000)
{
GetTitle(hd,hd->IndexGadgetPages[i]);
hd->IndexGadgets[i]=CreateMBoolGadget(hd->IndexWindow,x,y,hd->IGw,12,hd->Memory,i);
x+=hd->IGw+5;
if(x>550) { x=15; y+=15; }
}
else
{
if(x>15)
{
x=15; y+=15;
}
y+=10;
}
}
}
else hd->IGPCount=0;
GetPictures(hd,num);
/* ----- GadWindow öffnen --------------------------------------------- */
WindowToFront(hd->IndexWindow);
RefreshGadWindow(hd);
MakeMenu(hd);
}
VOID GetPictures(hd,num)
struct HelpData *hd;
UWORD num;
{
UBYTE byte;
REGISTER ULONG o;
o=POFFSET(num);
if(o!=0)
{
CacheSeek(hd,o,OFFSET_BEGINNING);
CacheRead(hd,&byte,1L);
while((byte!=0xFF)&&(hd->MenuPicCount<=hd->MaxItems))
{
hd->MenuPics[hd->MenuPicCount]=byte;
hd->MenuPicCount++;
CacheRead(hd,&byte,1L);
}
}
else hd->MenuPicCount=0;
}
VOID ShowTextPage(hd,num)
struct HelpData *hd;
UWORD num;
{
UBYTE *m;
UBYTE byte;
UWORD wort;
REGISTER UWORD i,j,k;
REGISTER ULONG o;
hd->MenuPageCount=0;
o=GOFFSET(num);
if(o!=0)
{
CacheSeek(hd,o,OFFSET_BEGINNING);
CacheRead(hd,&wort,2L);
while((wort!=0xFFFF)&&(hd->MenuPageCount<=hd->MaxItems))
{
hd->MenuPages[hd->MenuPageCount]=wort;
hd->MenuPageCount++;
CacheRead(hd,&wort,2L);
}
for(j=0;j<hd->MenuPageCount;j++)
{
if(hd->MenuPages[j]!=2000)
{
GetTitle(hd,hd->MenuPages[j]);
if((strlen(hd->Memory))>60) hd->Memory[59]=0x00;
strcpy(&hd->MenuNames[j],hd->Memory);
}
}
}
else hd->MenuPageCount=0;
GetPictures(hd,num);
MakeMenu(hd);
RefreshGadWindow(hd);
hd->CurrentLine=0xFFFF;
hd->LineCount=0;
for(i=0;i<2000;i++) hd->Lines[i]=NULL;
j=LENGTH(num);
CacheSeek(hd,TOFFSET(num),OFFSET_BEGINNING);
CacheRead(hd,hd->Memory,j);
i=0;
while(i<j)
{
hd->Lines[hd->LineCount]=&hd->Memory[i];
i+=(strlen(&hd->Memory[i])+1);
hd->LineCount++;
}
ShowPart(hd,0);
if(hd->LineCount>hd->Rows)
hd->PropBody=hd->LineCount-hd->Rows;
else
hd->PropBody=1;
NewProp(hd,hd->PropBody);
WindowToFront(hd->TextWindow);
}
VOID ShowPart(hd,part)
struct HelpData *hd;
UWORD part;
{
UBYTE s[6];
REGISTER BYTE test;
REGISTER UWORD i,j,k;
if(part==hd->CurrentLine) return;
if(!(hd->LineCount<=hd->Rows))
{
if(part>(hd->LineCount-hd->Rows)) part=hd->LineCount-hd->Rows;
/* part = Zeile, ab der gelistet werden soll
hd->CurrentLine = Zeile, ab der gelistet wird */
if(part>hd->CurrentLine)
{ test=3; if(part-hd->CurrentLine>=hd->Rows) test=1; }
else if(part<hd->CurrentLine)
{ test=4; if(hd->CurrentLine-part>=hd->Rows) test=1; }
else if(part==hd->CurrentLine)
{ test=1; }
switch(test)
{
case 1:
hd->CurrentLine=part;
ConWrite(hd,"\f");
for(i=part;i<part+hd->Rows;i++)
{
ConWrite(hd,hd->Lines[i]);
ConWrite(hd,"\n");
}
break;
case 3:
j=part-hd->CurrentLine;
k=hd->CurrentLine+hd->Rows;
for(i=k;i<(k+j);i++)
{
ConWrite(hd,hd->Lines[i]);
ConWrite(hd,"\n");
}
hd->CurrentLine+=j;
break;
case 4:
j=hd->CurrentLine-part;
k=hd->CurrentLine;
ConWrite(hd,"\x9b");
ConWrite(hd,"H");
for(i=(k-j);i<k;i++)
{
ConWrite(hd,"\x9b");
ConWrite(hd,"L");
ConWrite(hd,hd->Lines[i]);
ConWrite(hd,"\n");
}
sprintf(&s,"%ldH",(hd->Rows+1));
ConWrite(hd,"\x9b");
ConWrite(hd,&s);
ConWrite(hd,"\x9b");
ConWrite(hd,"M");
hd->CurrentLine-=j;
break;
}
}
else
{
ConWrite(hd,"\f");
for(i=0;i<hd->LineCount;i++)
{
ConWrite(hd,hd->Lines[i]);
ConWrite(hd,"\n");
}
}
}
VOID RemIndexGadgets(hd)
struct HelpData *hd;
{
UBYTE i;
struct Gadget *gad;
for(i=0;i<64;i++)
{
gad=hd->IndexGadgets[i];
if(gad!=NULL)
{
RemoveGadget(hd->IndexWindow,gad);
hd->IndexGadgets[i]=NULL;
hd->IndexGadgetPages[i]=0;
}
}
if(hd->IndexWindow->UserData!=NULL)
{
FreeRemember(&hd->IndexWindow->UserData,TRUE);
hd->IndexWindow->UserData=NULL;
}
SetAPen(hd->IndexRastPort,0);
RectFill(hd->IndexRastPort,0,0,582,210);
}
VOID NewProp(hd,v)
struct HelpData *hd;
UWORD v;
{
ModifyProp(hd->PropGadget,hd->MainWindow,NULL,
AUTOKNOB|PROPBORDERLESS|FREEVERT,0,0,0,65535/v);
}
struct MenuStrip
{
struct Window *Window;
struct TextAttr TextAttr;
UBYTE FrontPen;
UBYTE BackPen;
struct Menu *LastMenu;
struct MenuItem *LastItem;
struct MenuItem *LastSubItem;
struct Remember *Remember;
};
/* MenuStrip Grundstruktur erstellen */
struct MenuStrip *BuildMenuStrip(win,fp,bp)
struct Window *win;
UWORD fp,bp;
{
register struct MenuStrip *ms;
register struct RastPort *rp;
ms=AllocMem(sizeof(struct MenuStrip),MEMF_CLEAR|MEMF_PUBLIC);
if(ms!=NULL)
{
ms->Window=win;
rp=win->RPort;
ms->TextAttr.ta_Name=rp->Font->tf_Message.mn_Node.ln_Name;
ms->TextAttr.ta_YSize=rp->Font->tf_YSize;
ms->TextAttr.ta_Flags=rp->Font->tf_Flags;
ms->TextAttr.ta_Style=rp->AlgoStyle;
ms->FrontPen=fp;
ms->BackPen=bp;
}
return(ms);
}
struct Menu *AddMenu(ms,x,w,name)
struct MenuStrip *ms;
UWORD x,w;
UBYTE *name;
{
register struct Menu *me;
me=AllocRemember(&ms->Remember,sizeof(struct Menu),MEMF_CLEAR|MEMF_PUBLIC);
if(me!=NULL)
{
me->LeftEdge=x;
me->TopEdge=0;
me->Width=w;
me->Height=10;
me->Flags=MENUENABLED;
me->MenuName=name;
me->NextMenu=ms->LastMenu;
ms->LastMenu=me;
ms->LastItem=NULL;
ms->LastSubItem=NULL;
}
return(me);
}
struct MenuItem *AddItem(ms,name,w,cmd,enabled,highcomp)
struct MenuStrip *ms;
UBYTE *name;
UWORD w;
UBYTE cmd;
BOOL enabled,highcomp;
{
register struct Menu *me;
register struct MenuItem *mi;
register struct IntuiText *it;
me=ms->LastMenu;
if(me!=NULL)
{
mi=AllocRemember(&ms->Remember,sizeof(struct MenuItem)+sizeof(struct IntuiText),MEMF_CLEAR|MEMF_PUBLIC);
if(mi!=NULL)
{
it=(ULONG)mi+(ULONG)sizeof(struct MenuItem);
if(ms->LastItem!=NULL)
mi->TopEdge=ms->LastItem->TopEdge+10;
else
mi->TopEdge=0;
mi->LeftEdge=0;
mi->Width=w;
mi->Height=10;
mi->Flags=ITEMTEXT;
if(enabled) mi->Flags |= ITEMENABLED;
if(highcomp) mi->Flags |= HIGHCOMP; else mi->Flags |= HIGHNONE;
if(cmd!=0)
{
mi->Flags |= COMMSEQ;
mi->Command=cmd;
}
mi->ItemFill=it;
it->LeftEdge=AUTOLEFTEDGE;
it->TopEdge=1;
it->DrawMode=JAM1;
it->FrontPen=ms->FrontPen;
it->BackPen=ms->BackPen;
it->ITextFont=&ms->TextAttr;
it->IText=name;
mi->NextItem=ms->LastItem;
ms->LastItem=mi;
ms->LastSubItem=NULL;
me->FirstItem=mi;
}
}
return(mi);
}
VOID UseMenuStrip(ms)
struct MenuStrip *ms;
{
if(ms->LastMenu!=NULL) SetMenuStrip(ms->Window,ms->LastMenu);
}
VOID RemoveMenuStrip(ms,bool)
struct MenuStrip *ms;
BOOL bool;
{
ClearMenuStrip(ms->Window);
if(ms->Remember!=NULL) FreeRemember(&ms->Remember,TRUE);
ms->Remember=NULL;
ms->LastMenu=NULL;
ms->LastItem=NULL;
ms->LastSubItem=NULL;
if(bool==TRUE) FreeMem(ms,sizeof(struct MenuStrip));
}
UBYTE *GetOpalLine()
{
return((UBYTE *)"·········································································");
}
UBYTE *GetOpalLine450()
{
return((UBYTE *)"···············································································································");
}
VOID MacFormat(hd,tex,x)
struct HelpData *hd;
UBYTE *tex;
UWORD x;
{
REGISTER UWORD i,j,k,l;
k=strlen(tex);
l=TextLength(hd->MainRastPort,tex,k);
if(l>x)
{
i=0;
j=TextLength(hd->MainRastPort,"...",3);
l=j;
do
{
j+=TextLength(hd->MainRastPort,&tex[i],1L);
i++;
} while(j<x);
tex[i]=0x00;
strcat(tex,"...");
}
}
VOID MakeMenu(hd)
struct HelpData *hd;
{
REGISTER UWORD i,j;
RemoveMenuStrip(hd->MenuStrip,FALSE);
hd->DateiMenu=AddMenu(hd->MenuStrip,5,150,"Datei");
AddItem(hd->MenuStrip,"Einstellunden ändern",300,'E',TRUE,TRUE);
AddItem(hd->MenuStrip,"Bedienungshinweise",300,'B',TRUE,TRUE);
AddItem(hd->MenuStrip,"Information",300,'I',TRUE,TRUE);
AddItem(hd->MenuStrip,GetOpalLine(),300,0,FALSE,FALSE);
AddItem(hd->MenuStrip,"Hilfe beenden",300,'Q',TRUE,TRUE);
hd->QVMenu=AddMenu(hd->MenuStrip,160,150,"Querverweise");
if((hd->Flags==PAGE_TEXT)&&(hd->MenuPageCount>0))
{
for(i=0;i<hd->MenuPageCount;i++)
{
if(hd->MenuPages[i]!=2000)
{
MacFormat(hd,&hd->MenuNames[i],430);
AddItem(hd->MenuStrip,&hd->MenuNames[i],450,0,TRUE,TRUE);
}
else AddItem(hd->MenuStrip,GetOpalLine450(),450,0,FALSE,FALSE);
}
}
else AddItem(hd->MenuStrip,"Nicht verfügbar",300,0,TRUE,FALSE);
hd->BilderMenu=AddMenu(hd->MenuStrip,315,150,"Bilder");
if(hd->MenuPicCount>0)
{
for(i=0;i<hd->MenuPicCount;i++)
{
if(hd->MenuPics[i]!=200)
{
sprintf(&hd->MenuPicNames[i],"Abbildung #%ld",hd->MenuPics[i]+1);
AddItem(hd->MenuStrip,&hd->MenuPicNames[i],300,0,TRUE,TRUE);
}
else AddItem(hd->MenuStrip,GetOpalLine(),300,0,FALSE,FALSE);
}
}
else AddItem(hd->MenuStrip,"Nicht verfügbar",300,0,TRUE,FALSE);
UseMenuStrip(hd->MenuStrip);
ActivateWindow(hd->MainWindow);
}
UBYTE *String[]=
{
"",
"\x9b1;33;40m\x9b4;33;40mDie Bedienung des Online-Hilfesystems\x9b0;33;40m",
"",
"",
"",
"\x9b4;33;40mDie Auswahl von Seiten\x9b0;33;40m",
"",
"",
"Beim Aufruf des Hilfesystems wird zuerst der Hauptindex geladen. Durch",
"Klicken auf die Gadgets im Index gelangt man zu den entsprechenden",
"Seiten.",
"",
"Am unteren Bildschirmrand befindet sich mindestens ein Gadget; maximal",
"jedoch sechs. Mit ihnen kann zur nächsten bzw. vorhergehenden Seite ge-",
"wechselt werden oder die zuletzt angezeigten Seiten erneut sichten.",
"",
"Gadget-Positionen und ihre Funktionen",
"",
"[«] [......] [......] [......] [......] [»]",
" | | | | | |",
" | | | | | +-- Umkehrung von \"«\"",
" | | | | +-- nächste Indexseite",
" | | | +-- nächste Textseite",
" | | +-- vorhergehende Textseite",
" | +-- vorhergehende Indexseite",
" +-- zuletzt gezeigte Seite sichten",
"",
"",
"",
"\x9b4;33;40mDie Seitentypen\x9b0;33;40m",
"",
"",
"Indexseiten:",
"",
"Auf Indexseiten befinden sich Gadgets, die zu den entsprechenden Text-",
"seiten führen.",
"",
"",
"Textseiten:",
"",
"Auf diesen Seiten stehen die Hilfstexte. Ist der Text größer als der",
"im Textfenster zur Verfügung stehende Platz, so läßt sich der Text-",
"ausschnitt mit dem Proportional-Gadget am rechten Bildschirmrand ver-",
"schieben.",
"Besitzt die Seite Querverweise auf andere Seiten, so sind diese im",
"Menü \"Querverweise\" aufgelistet. Durch Anwahl des entsprechenden",
"Menüpunktes wird die Seite geladen.",
"Gleiches gilt für Bilder und Diagramme im Menü \"Bilder\".",
"",
"",
"",
"\x9b4;33;40mDas Datei-Menü\x9b0;33;40m",
"",
"",
"Der Menüpunkt \"Einstellungen ändern\"",
"",
"Hier lassen sich die Grundeinstellungen des Hilfesystems ändern:",
"",
"Cache-Modus: Die Hilfedatei wird beim Start komplett in den Haupt-",
" speicher geladen. Bei Systemen mit wenig Speicher kann",
" der Modus ausgeschaltet werden. Bei jeder neuen Seite",
" wird dann vom Datenträger nachgeladen.",
"",
"PAL-Modus: Es wird statt des amerikanischen NTSC-Videosystems",
" (600x200 Pixel) das europäische PAL-System (640x256 Pixel)",
" benutzt."
"",
"Seitennummern: Zusätzlich zum Seitentitel wird auch die Seitennummer",
" angezeigt. Über diese Nummern läuft die gesamte Seiten-",
" verwaltung; deshalb kann diese Funktion beim Einbau der",
" Online-Hilfe in eigene Programme sinnvoll sein. Für den",
" normalen Gebrauch werden diese Nummern nicht benötigt,",
" da die Seitenauswahl über die Maus läuft.",
"",
"SN-Eingabe: Ist diese Funktion eingeschaltet, so kann eine Seitennummer",
" direkt eingegeben werden: Wurde die erste Ziffer gedrückt,",
" so erscheint rechts oben neben dem Index-Gadget statt der",
" Seitentitelanzeige die Nummerneingabeanzeige. Die direkte",
" Seiteneingabe ist wie auch die Seitennummernanzeige nur",
" für Entwicklungszwecke gedacht und wird deshalb bei Nor-",
" malgebrauch nicht benötigt.",
"",
"",
"Der Menüpunkt \"Bedienungshinweise\"",
"",
"Hiermit wird dieser Text angezeigt.",
"",
"",
"Der Menüpunkt \"Information\"",
"",
"Hiermit werden Informationen über das Hilfesystem, die Version und",
"den noch freien Speicher im Amiga und auf einer eventuell vorhan-",
"denen PC/AT-Brückenkarte angezeigt.",
"",
"",
"Der Menüpunkt \"Hilfe beenden\"",
"",
"Hiermit wird das Hilfesystem geschlossen und in das Anwendungs-",
"programm zurückgekehrt.",
"",
"",
"",
"\x9b4;33;40mDas Querverweise-Menü\x9b0;33;40m",
"",
"In diesem Menü stehen Querverweise auf andere, zum Thema relevante",
"Seiten. Sie können durch Anwahl des entsprechendes Menüpunktes",
"gesichtet werden. Querverweise sind nicht auf allen Seiten.",
"",
"",
"",
"\x9b4;33;40mDas Bilder-Menü\x9b0;33;40m",
"",
"In diesem Menü befinden sich Bilder, die durch Anwahl der Menüpunkte",
"angezeigt werden. Bilder sind, wie Querverweise, nicht auf allen",
"Seiten.",
NULL
};
VOID Hinweise(hd)
struct HelpData *hd;
{
REGISTER UWORD i;
WindowToFront(hd->TextWindow);
RemIndexGadgets(hd);
hd->Flags=PAGE_TEXT;
hd->Page=1001;
hd->CurrentLine=0xFFFF;
i=0;
while(String[i]!=NULL)
{
hd->Lines[i]=String[i];
i++;
}
hd->LineCount=i;
for( ;i<2000;i++) hd->Lines[i]=NULL;
ShowPart(hd,0);
hd->PropBody=hd->LineCount-hd->Rows;
NewProp(hd,hd->PropBody);
WindowToFront(hd->TextWindow);
}
VOID Prefs(hd)
struct HelpData *hd;
{
REGISTER UWORD i,j;
register struct FileHandle *fh;
register struct Window *win;
register struct RastPort *rp;
register struct Gadget *g1,*g2,*g3,*g4;
static struct NewWindow PrefsWindowDef=
{
75,75,450,90,
0,1,
CLOSEWINDOW,
ACTIVATE|WINDOWDRAG|WINDOWCLOSE,
NULL,NULL,"Online-Hilfe - Einstellungen",NULL,NULL,
10,16,640,256,
CUSTOMSCREEN
};
PrefsWindowDef.Screen=hd->Screen;
win=OpenWindow(&PrefsWindowDef);
if(win!=NULL)
{
win->UserData=NULL;
rp=win->RPort;
SetFont(rp,hd->OpalFont);
if(hd->OHPrefs.Cache==0)
g1=CreateNToggleGadget(win,15,15,410,12,"Cache für Hilfedatei anlegen",1);
else
g1=CreateSToggleGadget(win,15,15,410,12,"Cache für Hilfedatei anlegen",1);
if(hd->OHPrefs.PAL==0)
g4=CreateNToggleGadget(win,15,30,410,12,"Europäisches PAL-Videosystem",4);
else
g4=CreateSToggleGadget(win,15,30,410,12,"Europäisches PAL-Videosystem",4);
SetAPen(rp,3);
WriteText(rp,20,52,"Spezialeinstellungen:");
if(hd->OHPrefs.Numbers==0)
g2=CreateNToggleGadget(win,15,57,410,12,"Anzeige mit Seitennummern",2);
else
g2=CreateSToggleGadget(win,15,57,410,12,"Anzeige mit Seitennummern",2);
if(hd->OHPrefs.NumInput==0)
g3=CreateNToggleGadget(win,15,72,410,12,"Direkte Seitennummereingabe",3);
else
g3=CreateSToggleGadget(win,15,72,410,12,"Direkte Seitennummereingabe",3);
WaitPort(win->UserPort);
ReplyMsg(GetMsg(win->UserPort));
if(g1->Flags & SELECTED) hd->OHPrefs.Cache=1; else hd->OHPrefs.Cache=0;
if(g2->Flags & SELECTED) hd->OHPrefs.Numbers=1; else hd->OHPrefs.Numbers=0;
if(g3->Flags & SELECTED) hd->OHPrefs.NumInput=1; else hd->OHPrefs.NumInput=0;
if(g4->Flags & SELECTED) hd->OHPrefs.PAL=1; else hd->OHPrefs.PAL=0;
DeleteStdWindow(win);
fh=Open(HelpName,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,&hd->OHPrefs,sizeof(struct OHPrefs));
Close(fh);
}
}
}
LONG CacheRead(hd,mem,len)
struct HelpData *hd;
UBYTE *mem;
ULONG len;
{
if(hd->CacheOn==0)
{
return(Read(hd->HelpFile,mem,len));
}
CopyMem(&hd->CacheMemory[hd->CachePos],mem,len);
hd->CachePos+=len;
return(len);
}
LONG CacheSeek(hd,pos,offset)
struct HelpData *hd;
LONG pos;
LONG offset;
{
if(hd->OHPrefs.Cache==0)
{
return(Seek(hd->HelpFile,pos,offset));
}
hd->CacheLastPos=hd->CachePos;
switch(offset)
{
case OFFSET_BEGINNING:
hd->CachePos=pos;
break;
case OFFSET_END:
hd->CachePos=hd->CacheSize+pos;
break;
}
return(hd->CacheLastPos);
}
VOID LoadAPicture(hd,num)
struct HelpData *hd;
UBYTE num;
{
LONG o;
ULONG size;
UBYTE byte;
REGISTER UBYTE *mem;
register struct FileHandle *fh;
o=hd->Picture[num];
if(o!=NULL)
{
CacheSeek(hd,o,OFFSET_BEGINNING);
CacheRead(hd,&byte,1L);
CacheRead(hd,&size,4L);
if(byte==0)
{
CacheRead(hd,&hd->String,199);
hd->String[199]=0x00;
ShowPicture(&hd->String);
}
else
{
if(hd->CacheOn!=0)
{
DisplayPicture(&hd->CacheMemory[hd->CachePos],size);
}
else
{
mem=AllocMem(size,MEMF_CLEAR|MEMF_PUBLIC);
if(mem!=NULL)
{
CacheRead(hd,mem,size);
DisplayPicture(mem,size);
FreeMem(mem,size);
}
}
}
}
}
struct BMHD
{
UWORD w,h,x,y;
UBYTE BitPlanes;
UBYTE Masking;
UBYTE Compression;
UBYTE pad;
UWORD TransCol;
UBYTE XA,YA;
UWORD Width,Height;
};
struct ColReg
{
UBYTE Red;
UBYTE Green;
UBYTE Blue;
};
struct CAMG
{
UWORD pad;
UWORD ViewModes;
};
struct CRNG
{
UWORD pad;
UWORD rate;
UWORD active;
UBYTE low,high;
};
struct RInfo
{
UBYTE *Memory;
ULONG Pos;
ULONG Max;
};
ULONG Lesen(ri,m,l)
struct RInfo *ri;
UBYTE *m;
ULONG l;
{
if((ri->Pos+l)>ri->Max) l=(ri->Max-ri->Pos);
CopyMem(&ri->Memory[ri->Pos],m,l);
ri->Pos+=l;
return(l);
}
VOID Jump(ri,l)
struct RInfo *ri;
ULONG l;
{
if((ri->Pos+l)>ri->Max) l=(ri->Max-ri->Pos);
ri->Pos+=l;
}
UBYTE ColorCount[]={1,2,4,8,16,32,32,32,32};
BOOL DisplayPicture(mem,len)
UBYTE *mem;
LONG len;
{
struct NewScreen ns;
UBYTE Buffer[300];
ULONG l;
BOOL BMHDFlag,BODYFlag,CMAPFlag,CAMGFlag,CRNGFlag,FoundChunk;
ULONG ChunkLen;
REGISTER UWORD BytesPerRow,bpr,y,ByteCount,h,i;
REGISTER UBYTE b;
ULONG dest;
register struct Screen *scr;
struct BMHD bmhd;
struct CAMG camg;
struct CRNG crng;
struct ColReg Farben[32];
UWORD AnzFarben;
struct ColReg Farbe;
struct RInfo *fh;
struct RInfo ri;
ri.Memory=mem;
ri.Pos=0;
ri.Max=len;
fh=&ri;
Lesen(fh,&Buffer,12);
if(strncmp(&Buffer[0],"FORM",4)!=0)
{ InfoRequest("Bild hat kein IFF-Format!");
return(FALSE); }
if(strncmp(&Buffer[8],"ILBM",4)!=0)
{ InfoRequest("Bild hat kein ILBM-Format!");
return(FALSE); }
BMHDFlag=FALSE;
BODYFlag=FALSE;
CAMGFlag=FALSE;
CMAPFlag=FALSE;
CRNGFlag=FALSE;
Loop:
FoundChunk=FALSE;
l=Lesen(fh,&Buffer,8);
if((l==0)||((BMHDFlag==TRUE)&&(BODYFlag==TRUE)&&(CMAPFlag==TRUE)))
{
if((BMHDFlag==TRUE)&&(BODYFlag==TRUE)&&(CMAPFlag==TRUE))
{
ShowTitle(scr,FALSE);
if(CRNGFlag==TRUE)
{
if(crng.active!=0)
{
h=crng.rate/273;
if(h==0) h=1;
y=50/h;
while((MouseButton())==0)
{
Farbe.Red=Farben[crng.low].Red;
Farbe.Green=Farben[crng.low].Green;
Farbe.Blue=Farben[crng.low].Blue;
for(i=crng.low;i<crng.high;i++)
{
Farben[i].Red=Farben[i+1].Red;
Farben[i].Green=Farben[i+1].Green;
Farben[i].Blue=Farben[i+1].Blue;
}
Farben[crng.high].Red=Farbe.Red;
Farben[crng.high].Green=Farbe.Green;
Farben[crng.high].Blue=Farbe.Blue;
for(i=crng.low;i<crng.high;i++)
{
SetRGB4(&scr->ViewPort,i,Farben[i].Red,
Farben[i].Green,
Farben[i].Blue);
}
Delay(y);
}
}
}
else
{
while((MouseButton())==0)
Delay(5);
}
CloseScreen(scr);
return(TRUE);
}
else
{
if((BMHDFlag==TRUE)||(BODYFlag==TRUE)||(CMAPFlag==TRUE))
{
if(BMHDFlag==FALSE) InfoRequest("Bild hat keinen BMHD-Chunk!");
else if(BODYFlag==FALSE) InfoRequest("Bild hat keinen BODY-Chunk!");
else if(CMAPFlag==FALSE) InfoRequest("Bild hat keinen CMAP-Chunk!");
if(scr!=NULL) CloseScreen(scr);
return(FALSE);
}
}
}
ChunkLen=Buffer[4]*16777216+Buffer[5]*65536+Buffer[6]*256+Buffer[7];
if(strncmp(&Buffer,"BMHD",4)==0)
{
Lesen(fh,&bmhd,ChunkLen);
if(bmhd.Compression>1)
{
InfoRequest("Unbekannte Kompressionsmethode!");
return(FALSE);
}
ns.LeftEdge = 0;
ns.TopEdge = 0;
ns.Width = bmhd.Width;
ns.Height = bmhd.Height;
ns.Depth = bmhd.BitPlanes;
ns.DetailPen = 1;
ns.BlockPen = 0;
if(CAMGFlag==TRUE)
{
ns.ViewModes = camg.ViewModes;
}
else
{
if(ns.Width>320) ns.ViewModes |= HIRES;
if(ns.Height>256) ns.ViewModes |= LACE;
}
ns.Type = CUSTOMSCREEN;
ns.Font = NULL;
ns.DefaultTitle = "Ende mit Mausklick";
ns.Gadgets = NULL;
ns.CustomBitMap = NULL;
scr=OpenScreen(&ns);
if(scr==NULL)
{
InfoRequest("Kann Screen nicht öffnen!");
return(FALSE);
}
BytesPerRow=bmhd.Width/8;
bpr=(bmhd.w+1)/8;
h=bmhd.h+1;
BMHDFlag=TRUE;
FoundChunk=TRUE;
}
if(strncmp(&Buffer,"CMAP",4)==0)
{
if(BMHDFlag==FALSE)
{ InfoRequest("BMHD-Chunk muß vor CMAP-Chunk stehen!");
return(FALSE); }
AnzFarben=ColorCount[bmhd.BitPlanes];
for(i=0;i<AnzFarben;i++)
{
Lesen(fh,&Farbe,3);
Farben[i].Red=Farbe.Red>>4;
Farben[i].Green=Farbe.Green>>4;
Farben[i].Blue=Farbe.Blue>>4;
SetRGB4(&scr->ViewPort,i,Farben[i].Red,
Farben[i].Green,
Farben[i].Blue);
}
CMAPFlag = TRUE;
FoundChunk = TRUE;
}
if(strncmp(&Buffer,"BODY",4)==0)
{
if(BMHDFlag==FALSE)
{ InfoRequest("BMHD-Chunk muß vor BODY-Chunk stehen!");
return(FALSE); }
for(y=0;y<h;y++)
{
for(b=0;b<bmhd.BitPlanes;b++)
{
ByteCount=0;
dest=(ULONG)((ULONG)(scr->RastPort.BitMap->Planes[b])+y*BytesPerRow+bmhd.x);
if(bmhd.Compression==0)
{
Lesen(fh,dest,bpr);
}
else
{
while(ByteCount<bpr)
{
Lesen(fh,&Buffer[0],1);
if(Buffer[0]<128)
{
Lesen(fh,dest+(ULONG)ByteCount,Buffer[0]+1);
ByteCount += Buffer[0]+1;
}
if(Buffer[0]>128)
{
Lesen(fh,&Buffer[1],1);
for(i=ByteCount;i<(ByteCount+(257-Buffer[0]));i++)
{ *((UBYTE *)dest+(UBYTE *)i)=Buffer[1]; }
ByteCount += 257-Buffer[0];
}
}
}
}
}
BODYFlag = TRUE;
FoundChunk = TRUE;
}
if(strncmp(&Buffer,"CAMG",4)==0)
{
Lesen(fh,&camg,ChunkLen);
if(BMHDFlag==FALSE)
{ InfoRequest("BMHD-Chunk muß vor CAMG-Chunk stehen!");
return(FALSE); }
scr->ViewPort.Modes=camg.ViewModes;
RemakeDisplay();
CAMGFlag = TRUE;
FoundChunk = TRUE;
}
if(strncmp(&Buffer,"CRNG",4)==0)
{
if(CRNGFlag==FALSE)
{
Lesen(fh,&crng,ChunkLen);
CRNGFlag = TRUE;
FoundChunk = TRUE;
}
}
if(FoundChunk==FALSE)
{
Jump(fh,ChunkLen);
if(ChunkLen & 1) Jump(fh,1);
}
goto Loop;
}
BOOL ShowPicture(name)
UBYTE *name;
{
REGISTER UBYTE *mem;
REGISTER ULONG size;
register struct FileHandle *fh;
fh=Open(name,MODE_OLDFILE);
if(fh!=NULL)
{
Seek(fh,0,OFFSET_END);
size=Seek(fh,0,OFFSET_BEGINNING);
mem=AllocMem(size,MEMF_CLEAR|MEMF_PUBLIC);
if(mem!=NULL)
{
DisplayPicture(mem,size);
FreeMem(mem,size);
}
}
else return(FALSE);
return(TRUE);
}
#asm
public _MouseButton
_MouseButton:
btst #6,$bfe001
bne 1$
move.l #1,d0
rts
1$:
clr.l d0
rts
#endasm
VOID AddPage(hd)
struct HelpData *hd;
{
REGISTER UBYTE i;
hd->ShowLastPageBack=0;
hd->LastPageSelect=hd->LastPagePos;
if(hd->LastPagePos<PAGE_MEMORY)
{
hd->LastPage[hd->LastPagePos]=hd->Page;
hd->LastPagePos++;
}
else
{
for(i=0;i<PAGE_MEMORY;i++)
{
hd->LastPage[i]=hd->LastPage[i+1];
}
hd->LastPage[PAGE_MEMORY-1]=hd->Page;
hd->LastPageSelect=PAGE_MEMORY-1;
}
}